package tech.aistar.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.aistar.mapper.JobMapper;
import tech.aistar.model.entity.Job;
import tech.aistar.service.IJobService;

import java.util.List;

@Service
public class JobServiceImpl implements IJobService {
    @Autowired
    private JobMapper jobMapper;


    @Override
    public PageInfo<Job> findJobByCompanyId(Integer pageNum, Integer cId) {
        PageHelper.startPage(pageNum,4);
        List<Job> jobs=jobMapper.getAllByCompanyId(cId);
        PageInfo<Job> pageInfo=new PageInfo<>(jobs);
        return pageInfo;
    }

    @Override
    public Job findJobById(Integer id) {
        return jobMapper.getById(id);
    }

    @Override
    public PageInfo<Job> findAllJob(Integer pageNum) {
        PageHelper.startPage(pageNum,8);
        List<Job> jobs=jobMapper.getAllJob();
        PageInfo<Job> pageInfo=new PageInfo<>(jobs);
        return pageInfo;
    }

    @Override
    public PageInfo<Job> findAllJob6(Integer pageNum) {
        PageHelper.startPage(pageNum,6);
        List<Job> jobs=jobMapper.getAllJob();
        PageInfo<Job> pageInfo=new PageInfo<>(jobs);
        return pageInfo;
    }

    @Override
    public PageInfo<Job> findJobByCity(Integer pageNum, String city) {
        PageHelper.startPage(pageNum,8);
        List<Job> jobs=jobMapper.getBycity(city);
        PageInfo<Job> pageInfo=new PageInfo<>(jobs);
        return pageInfo;
    }

    @Override
    public PageInfo<Job> findJobBySchool(Integer pageNum, Integer school) {
        PageHelper.startPage(pageNum,8);
        List<Job> jobs=jobMapper.getBySchoolLevel(school);
        PageInfo<Job> pageInfo=new PageInfo<>(jobs);
        return pageInfo;
    }

    @Override
    public PageInfo<Job> findJobByMinMoney(Integer pageNum, Integer money) {
        PageHelper.startPage(pageNum,8);
        List<Job> jobs=jobMapper.getByMinMoney(money);
        PageInfo<Job> pageInfo=new PageInfo<>(jobs);
        return pageInfo;
    }

    @Override
    public PageInfo<Job> findJobByButton(Integer pageNum, String jobName) {
        PageHelper.startPage(pageNum,8);
        List<Job> jobs=jobMapper.getLikeName(jobName);
        PageInfo<Job> pageInfo=new PageInfo<>(jobs);
        return pageInfo;
    }
}
